package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController(value = "adminOrderController")
@RequestMapping("/admin/order/")
@Slf4j
@Api(tags = "订单管理接口")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @ApiOperation("订单分页展示")
    @GetMapping("/conditionSearch")
    public Result page(OrdersPageQueryDTO dto) {

        return orderService.page(dto);
    }

    @ApiOperation("订单状态统计")
    @GetMapping("/statistics")
    public Result count() {
        return orderService.count();
    }

    @ApiOperation("后台取消订单接口")
    @PutMapping("/cancel")
    public Result adminCancel(@RequestBody OrdersCancelDTO dto) {
        return orderService.adminCancel(dto);
    }

    @ApiOperation("查询订单详情")
    @GetMapping("/details/{id}")
    public Result orderDetail(@PathVariable Long id) {
        return orderService.orderDetail(id);
    }

    @ApiOperation("据单接口")
    @PutMapping("/rejection")
    public Result rejection(@RequestBody OrdersRejectionDTO dto) {
        return orderService.rejection(dto);

    }
    @ApiOperation("接单")
    @PutMapping("/confirm")
    public Result confirm(@RequestBody OrdersConfirmDTO dto){
        return orderService.confirm(dto);

    }
    @ApiOperation("订单派送")
    @PutMapping("/delivery/{id}")
    public Result delivery(@PathVariable Long id){
        return orderService.delivery(id);

    }
    @ApiOperation("完成订单")
    @PutMapping("/complete/{id}")
    public Result complete(@PathVariable Long id){
        return orderService.complete(id);
    }

}

